feat: Replace mutable buffers with immutable Arrow vectors in NativeBatchReader#3382
Closed
andygrove wants to merge 11 commits into
Closed
feat: Replace mutable buffers with immutable Arrow vectors in NativeBatchReader#3382andygrove wants to merge 11 commits into
andygrove wants to merge 11 commits into
Conversation
…mentation The documentation incorrectly claimed that native_iceberg_compat "removes the use of reusable mutable-buffers". In reality, both native_comet and native_iceberg_compat use reusable mutable buffers when transferring data via Arrow FFI. This commit: - Removes the inaccurate claim - Replaces it with accurate description of Parquet decoding delegation - Adds a note explaining the actual mutable buffer behavior - Links to the FFI documentation for details on arrow_ffi_safe flag Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Clarified note on mutable buffers and updated details on `native_iceberg_compat` implementation.
…ader Add ImmutableConstantColumnReader that creates Arrow vectors directly in Java without using native Rust mutable buffers. This is used for partition columns and missing columns in NativeBatchReader. Key changes: - New ImmutableConstantColumnReader creates Arrow vectors using Arrow Java APIs, supporting primitive types (Boolean, Byte, Short, Integer, Long, Float, Double, String, Binary, Date, Timestamp, Decimal, Null) - NativeBatchReader now uses ImmutableConstantColumnReader instead of ConstantColumnReader for partition and missing columns - CometScanRule checks partition column types at planning time and falls back to Spark if complex types (StructType, ArrayType, MapType) are used, since ImmutableConstantColumnReader only supports primitives Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3382 +/- ##
============================================
+ Coverage 56.12% 59.38% +3.25%
- Complexity 976 1463 +487
============================================
Files 119 176 +57
Lines 11743 16358 +4615
Branches 2251 2728 +477
============================================
+ Hits 6591 9714 +3123
- Misses 4012 5288 +1276
- Partials 1140 1356 +216 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
Author
|
Moving this to draft until we have benchmarks to ensure there is no regression with this change |
Instead of materializing full N-element Arrow arrays for partition and missing columns, export 1-element arrays from JVM and expand them on the native side using ScalarValue. This avoids O(N) memory allocation and copying for constant columns. - Add CometConstantVector: stores a single value, lazily creates a 1-element Arrow vector for FFI export, returns constant for all rowIds - Modify ImmutableConstantColumnReader to produce CometConstantVector - Add CometConstantVector case in NativeUtil.exportBatch() to skip row count validation for 1-element vectors - In scan.rs, detect 1-element arrays and expand via ScalarValue when actual_num_rows > 1; skip take() for scalar columns with selection vectors since constants are unaffected by row deletion Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds a benchmark that writes a partitioned parquet table and measures scan performance with 1 and 5 partition columns. Tests both reading data columns alongside partitions and reading partition columns themselves. This exercises the CometConstantVector → native scalar expansion path. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds a standalone benchmark that writes partitioned parquet tables and measures scan performance with 1 and 5 partition columns. Tests both reading data columns alongside partitions and reading partition columns themselves. This exercises the CometConstantVector path where constant columns are exported as 1-element Arrow arrays and expanded on the native side. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Member
Author
|
This approach is too slow. I am going to try some other approaches. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale
I would like to remove the remaining mutable buffer use from Comet so that we can use Arrow FFI best practices.
Summary
ImmutableConstantColumnReaderthat creates Arrow vectors directly in Java without using native Rust mutable buffers, used for partition columns and missing columns inNativeBatchReaderCometScanRulechecks partition column types at planning time and falls back to Spark if complex types (StructType, ArrayType, MapType) are usedTest plan
🤖 Generated with Claude Code